package spaces;

import math.Summable;
import vectors.Vector;
//TODO: create emptyCharge() and maybe get/setCharge() functions
public class ChargeableVectorNode extends VectorNode implements Chargeable{

	protected Vector charge;
	
	public ChargeableVectorNode(String name) {
		super(name);
	}

	public ChargeableVectorNode(String name, Vector pos) {
		super(name, pos);
		charge = Vector.zero(pos.getNOD());
	}
	
	@Override
	public void setPos(Vector pos){
		super.setPos(pos);
		if(charge == null){
			charge = Vector.zero(pos.getNOD());
		}
	}
	
	@Override
	public void addCharge(Summable ch){
		charge = charge.plus((Vector)ch);
	}
	
	@Override
	public void applyCharge(){
		location = getLocation().plus(charge);
		charge = Vector.zero(charge.getNOD());
	}

	public Vector getCharge() {
		return charge;
	}

}
